package tani.bnn.com.mbilling.utility;

import org.apache.xmlbeans.impl.util.Base64;

public class DecodeEncodeUtil {
	private static final String ENCODE = "encode";
	private static final String DECODE = "decode";
	public static String encode(String strDecoded){
		String strEncoded = null;
		if(strDecoded != null && strDecoded.length() > 0){
			strEncoded = new String(Base64.encode(strDecoded.getBytes()));
		} else {
			strEncoded = "";
		}
		return strEncoded;
	}
	public static String decode(String strEncoded){
		String strDecoded = null;
		if(strEncoded != null && strEncoded.length() > 0){
			strDecoded = new String(Base64.decode(strEncoded.getBytes()));
		} else {
			strDecoded = "";
		}
		return strDecoded;
	}
	public static void main(String[] args){
		if(args.length == 2){
			if(DecodeEncodeUtil.ENCODE.equalsIgnoreCase(args[0])){
				System.out.println(encode(args[1]));
			}
			if(DecodeEncodeUtil.DECODE.equalsIgnoreCase(args[0])){
				System.out.println(decode(args[1]));
			}
		}
	}
}
